package com.apexedu.biz.action;

import com.apexedu.biz.service.impl.ResetPasswordServiceImpl;
import com.apexedu.framework.service.BaseService;
import com.apexedu.identity.entity.TSysUser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 重置密码
 * Created by hc on 2014/12/24.
 */
@SuppressWarnings("serial")
@Component
@Scope("prototype")
public class ResetPasswordAction extends BizBaseAction {
    @Resource(name = "resetPasswordService")
    public void setBaseService(BaseService baseService) {
        super.setBaseService(baseService);
    }

    private static final Log LOG = LogFactory.getLog(ResetPasswordAction.class);

    private TSysUser tsysUser;

    public TSysUser getTsysUser() {
        return tsysUser;
    }

    public void setTsysUser(TSysUser tsysUser) {
        this.tsysUser = tsysUser;
    }

    /**
     * 重置密码
     */
    public void doReset() {
        ResetPasswordServiceImpl service = (ResetPasswordServiceImpl) this.getBaseService();
        String mes = null;
        try {
            boolean flag = service.doReset(this);
            if (flag) {
                mes = "重置成功!";
            } else {
                mes = "重置失败!";
            }
        } catch (Exception e) {
            mes = "重置失败!";
            LOG.error(e.getMessage());
        } finally {
            putResultStringToView(mes);
        }
    }
}
